<?php
/**
 * Description of index
 * 
 * @author anhducbkhn
 * @since Oct 14, 2013 - 4:26:01 PM
 */
?>
<div class="row-fluid">
    <div class="box span12">
        <div class="box-header">
            <h2><i class="icon-cogs"></i><span class="break"></span>
                Hotdeal
            </h2>         
        </div>
        <div class="box-content">
            <?
            //register css file
            Yii::app()->clientScript->registerCssFile($this->assetDir . 'css/kdt/user.css');
            ?>
            <?php if (!$services): ?>
                <div class="box-content alerts">
                    <div class="alert alert-error">
                        <button type="button" class="close" data-dismiss="alert">×</button>
                        Sorry, there is nothing that matches your search.
                    </div>
                </div>
            <?php else: ?>
                <?php if (Yii::app()->user->hasFlash('success')): ?>
                    <div class="alert alert-success">
                        <button type="button" class="close" data-dismiss="alert">×</button>
                        <strong>All done!</strong> <?php echo Yii::app()->user->getFlash('success'); ?>
                    </div>
                <?php endif; ?>
                <form method="POST" action="<?php echo $this->createUrl('hotdeal/Add') ?>">
                    <h2><span class="badge badge-info">Services</span></h2>
                    <div class="table-responsive"> 
                        <table class="table table-bordered table-striped table-condensed">
                            <thead>
                                <tr>
                                    <th>Name service</th>
                                    <th>Price</th>
                                    <th>Biz Owner</th>
                                    <th>Add/Remove</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php foreach ($services as $sv): ?>
                                    <tr>
                                        <td>
                                            <a class="quick-detail" data-rel="popover"
                                               data-html="true" data-delay="1" data-trigger="click"
                                               data-content='<?php
                                               echo $this->renderPartial('/service/_quick_detail', array(
                                                   'sv' => $sv
                                               ));
                                               ?>' >
                                                   <?php echo $sv->s_name; ?>
                                            </a>
                                        </td>
                                        <td><?php echo $sv->price; ?></td>
                                        <td>
                                            <a href="<?php echo $sv->user->editUrl ?>">
                                                <?php echo $sv->user->name; ?>
                                            </a>
                                        </td>
                                        <td class="center">
                                            <input type="checkbox" name="Service[]" value="<?php echo $sv->sid ?>"
                                                   <?php echo Hotdeal::checkAdded($sv->sid) ? 'checked="checked"' : '' ?>>
                                        </td>
                                    </tr>
                                <?php endforeach; ?>
                            </tbody>
                        </table>
                    </div>
                    <div class="pagination pagination-centered clearfix">
                        <?php
                        $this->widget('application.widgets.MyLinkPager', array(
                            'actionPrefix'         => 'service',
                            'pages'                => $pages,
                            'header'               => '',
                            'maxButtonCount'       => 5,
                            'nextPageLabel'        => '&raquo;',
                            'firstPageLabel'       => '←',
                            'lastPageLabel'        => '→',
                            'prevPageLabel'        => '&laquo;',
                            'selectedPageCssClass' => 'active',
                        ))
                        ?>
                    </div>
                    <!--Class-->
                    <h2><span class="badge badge-warning">Classes</span></h2>
                    <div class="table-responsive"> 
                        <table class="table table-bordered table-striped table-condensed">
                            <thead>
                                <tr>
                                    <th>Name service</th>
                                    <th>Date</th>
                                    <th>Slots status</th>
                                    <th>Biz Owner</th>
                                    <th>Add/Remove</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php foreach ($classes as $class): ?>
                                    <tr>
                                        <td>
                                            <a class="quick-detail" data-rel="popover"
                                               data-html="true" data-delay="1" data-trigger="click"
                                               data-content='<?php
                                               echo $this->renderPartial('/service/_quick_detail', array(
                                                   'sv' => $class->service
                                               ));
                                               ?>' >
                                                   <?php echo $class->service->s_name; ?>
                                            </a>
                                        </td>
                                        <td><?php echo $class->formatDate(); ?>, <?php echo $class->startTime ?></td>
                                        <td><span class="badge badge-success"><b><?php echo $class->getCustomersize() ?></b></span></td>
                                        <td>
                                            <a href="<?php echo $class->service->user->editUrl ?>">
                                                <?php echo $class->service->user->name; ?>
                                            </a>
                                        </td>
                                        <td class="center">
                                            <input type="checkbox" name="Class[]" value="<?php echo $class->apt_id ?>"
                                                   <?php echo Hotdeal::checkAdded($class->apt_id, TRUE) ? 'checked="checked"' : '' ?>>
                                        </td>
                                    </tr>
                                <?php endforeach; ?>
                            </tbody>
                        </table>
                    </div>
                    <div class="pagination pagination-centered clearfix">
                        <?php
                        $this->widget('application.widgets.MyLinkPager', array(
                            'actionPrefix'         => 'class',
                            'pages'                => $pages_classes,
                            'header'               => '',
                            'maxButtonCount'       => 5,
                            'nextPageLabel'        => '&raquo;',
                            'firstPageLabel'       => '←',
                            'lastPageLabel'        => '→',
                            'prevPageLabel'        => '&laquo;',
                            'selectedPageCssClass' => 'active',
                        ))
                        ?>
                    </div>
                    <button class="btn btn-primary pull-right" type="submit">
                        <?php echo Yii::t('form', 'Save') ?>
                    </button>
                    <div class="clearfix"></div>
                </form>
            <?php endif; ?>
        </div>
    </div>
</div>